﻿using Disco.Ontology;
using Microsoft.Data.Edm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.OData.Builder;
using Disco.Web.Api.Controllers.Dynamic;
using System.Web.Http.Dispatcher;
using System.Web.Http.Cors;
using System.Configuration;
using System.Web.Http.Batch;

namespace Disco.Web.Api
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpBatchRoute(
                    routeName: "batch",
                    routeTemplate: "api/batch",
                    batchHandler: new DefaultHttpBatchHandler(GlobalConfiguration.DefaultServer));
            
            // HINT: The order of route definition matters! Hence preserve sequence below.
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            config.Routes.MapHttpRoute(
                name: "ActionApi",
                routeTemplate: "{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.EnableSystemDiagnosticsTracing();
        }
    }
}
